<?php
/**
 * 页面逻辑层
 * @author maniac
 */
namespace app\common\logic;

class Pages extends Base
{
    /**
     * 重组提交信息
     * @param  array $data 请求的信息
     */
    public function recombine($data)
    {
        $data['userid']   = session('userid', '', session_prefix());
        $data['username'] = session('username', '', session_prefix());
        $data['titlepic'] = isset($data['titlepic']) ? (int)$data['titlepic'] : 0;
        if (isset($data['file']) && $data['file']) {
            $arr = [];
            foreach ($data['file']['name'] as $k => $v) {
                $arr[$k] = [
                    'value' => $data['file']['value'][$k],
                    'name'  => $v,
                ];
            }
            $data['file'] = !empty($arr) ? serialize($arr) : '';
        } else {
            $data['file'] = '';
        }
        return $data;
    }
}
